<?php
namespace App\Policies\Admin;

use App\Models\AdminUser;
use App\Models\Department;

class DepartmentPolicy
{
    public $model;
    protected $admin_user;
    protected $xref_exists = false;
    protected $is_super_manger;
    protected $configs;
    protected $end_time;

    public function __construct(Department $model = null, AdminUser $admin_user = null)
    {
        $this->model = $model;
        $this->admin_user = $admin_user;
        $this->is_super_manger = $admin_user->isSuperManger();
        $this->end_time = "2024-02-01 00:00:00";
    }

    /**
     * 是否可以审核
     */
    public function can_verify()
    {
        if (!$this->is_super_manger) {
            return false;
        }
        # 必须是待审核的状态
        if ($this->model->status != Department::STATUS_VERIFY_PENDING) {
            return false;
        }
        return true;
    }

    public function can_download_zip()
    {
        if ($this->model->status == Department::STATUS_NORMAL) {
            return false;
        }
        if ($this->is_super_manger) {
            return true;
        }
        return true;
    }

    public static function make(...$params)
    {
        return new static(...$params);
    }
}